package com.jhzn.geomap.service;

import com.jhzn.geomap.mapper.PolygonMapper;
import com.jhzn.geomap.model.Polygon;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PolygonService {
    private final PolygonMapper polygonMapper;

    public PolygonService(PolygonMapper polygonMapper) {
        this.polygonMapper = polygonMapper;
    }

    public Polygon createPolygon(Polygon polygon) {
        polygonMapper.insert(polygon);
        return polygon;
    }

    public Polygon updatePolygon(Polygon polygon) {
        polygonMapper.update(polygon);
        return polygon;
    }

    public List<Polygon> getAllPolygons() {
        return polygonMapper.findAll();
    }

    public void deletePolygon(Long id) {
        polygonMapper.delete(id);
    }
}